package com.copyctrl.campus.common.domain;

import com.copyctrl.campus.common.constant.RedisKind;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author:JH
 * @version:1.0
 * useFor是否启用循环
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RedisData<T> {
    private RedisKind kind;
    private T data;
    private Collection<T> dataList;
    private String methodName;
    private Object key;
    private boolean useFor;
    /**
     * 用于存放hash数据
     */
    private Map dataMap;
    public static <T> RedisData getRedisList(Class<T> T,RedisKind kind,Collection<T> dataList,String operate,String key){
        return new RedisData(kind,null,dataList,operate,key,false,null);
    }
    public static <T> RedisData getRedisData(Class<T> T,RedisKind kind,T data,String operate,String key){
        return new RedisData(kind,data,null,operate,key,false,null);
    }
    public static <T> RedisData getRedisListUseFor(Class<T> T,RedisKind kind,Collection<T> dataList,String operate,String key){
        return new RedisData(kind,null,dataList,operate,key,true,null);
    }
    public static <T> RedisData getRedisDataMap(RedisKind kind,Map dataMap,String operate,String key){
        return new RedisData(kind,null,null,operate,key,true,dataMap);
    }
}
